<template>
	<div>
		<div class="btn-list-box">
			<p class="backgroundTitelBox">
				{{ $t('member.essential_infor') }}
			</p>
			<el-button
				type="primary"
				icon="el-icon-refresh"
				@click="refresh"
				:loading="refreshLoading"
			>
				{{ $t('common.refresh') }}
			</el-button>
			<p class="editMsg">
				<i class="el-icon-edit-outline"></i>
				<br />
				{{ $t('common.edit') }}
			</p>
			<el-button
				v-if="hasPermission('101033')"
				size="mini"
				type="primary"
				@click="handleEdit($t('common.account_status'))"
			>
				{{ $t('common.account_status') }}
			</el-button>
			<!-- <el-button
				v-if="hasPermission('101034')"
				size="mini"
				type="primary"
				@click="handleEdit($t('common.risk_control_level'))"
			>
				{{ $t('common.risk_control_level') }}
			</el-button>
			<el-button
				v-if="hasPermission('101035')"
				size="mini"
				type="primary"
				:disabled="btnPower.includes(6)"
				@click="handleEdit($t('member.label_name'))"
			>
				{{ $t('member.label_name') }}
			</el-button> -->
			<!-- <el-button
				v-if="hasPermission('101037')"
				size="mini"
				type="primary"
				:disabled="btnPower.includes(4)"
				@click="handleEdit($t('member.phone_number'))"
			>
				{{ $t('member.phone_number') }}
			</el-button> -->
			<el-button
				v-if="hasPermission('101036')"
				size="mini"
				type="primary"
				:disabled="btnPower.includes(3)"
				@click="handleEdit($t('member.date_of_birth'))"
			>
				{{ $t('member.date_of_birth') }}
			</el-button>
			<!-- 会员昵称修改按钮 -->
			<el-button
				v-if="hasPermission('90060045')"
				size="mini"
				type="primary"
				:disabled="btnPower.includes(8)"
				@click="handleEdit($t('member.nickname'))"
			>
				{{ $t('member.nickname') }}
			</el-button>
			<!-- <el-button
				v-if="hasPermission('101038')"
				size="mini"
				type="primary"
				:disabled="btnPower.includes(1)"
				@click="handleEdit($t('common.name'))"
			>
				{{ $t('common.name') }}
			</el-button> -->
			<el-button
				v-if="hasPermission('101039')"
				size="mini"
				type="primary"
				:disabled="btnPower.includes(2)"
				@click="handleEdit($t('member.gender'))"
			>
				{{ $t('member.gender') }}
			</el-button>
			<!-- <el-button
				v-if="hasPermission('101045')"
				size="mini"
				type="primary"
				:disabled="btnPower.includes(5)"
				@click="handleEdit($t('member.mailbox'))"
			>
				{{ $t('member.mailbox') }}
			</el-button> -->
			<el-button
				v-if="hasPermission('101046')"
				size="mini"
				type="primary"
				@click="handleEdit($t('member.account_remarks'))"
			>
				{{ $t('member.account_remarks') }}
			</el-button>
			<!--
			<el-button
				v-if="hasPermission('101048')"
				size="mini"
				type="primary"
				@click="handleEdit($t('member.activity_flow_limit'))"
			>
				{{ $t('member.activity_flow_limit') }}
			</el-button> -->
			<el-button
				v-if="hasPermission('101057')"
				size="mini"
				type="primary"
				:disabled="btnPower.includes(7)"
				@click="handleEdit($t('member.login_password_reset'))"
			>
				{{ $t('member.login_password_reset') }}
			</el-button>
			<el-button
				v-if="hasPermission('101047')"
				size="mini"
				type="primary"
				@click="handleEdit($t('member.credit_rating'))"
			>
				{{ $t('member.credit_rating') }}
			</el-button>
			<el-button
				v-if="hasPermission('90150024')"
				size="mini"
				type="primary"
				:disabled="btnPower.includes(10)"
				@click="handleEdit($t('member.withdrawals_password_reset'))"
			>
				{{ $t('member.withdrawals_password_reset') }}
			</el-button>
			<!-- <el-button
				v-if="hasPermission('90810064')"
				size="mini"
				type="primary"
				:disabled="btnPower.includes(11)"
				@click="handleEdit($t('member.rebate_status'))"
			>
				{{ $t('member.rebate_status') }}
			</el-button> -->

			<el-button
				v-if="hasPermission('90810065')"
				size="mini"
				type="primary"
				:disabled="btnPower.includes(11)"
				@click="handleEdit($t('member.bmh_account_unbind'))"
			>
				{{ $t('member.bmh_account_unbind') }}
			</el-button>
			<el-button
				v-if="hasPermission('909300687')"
				size="mini"
				type="primary"
				@click="handleEdit($t('member.yh_account_unbind'))"
			>
				{{ $t('member.yh_account_unbind') }}
			</el-button>
			<el-button
				v-if="hasPermission('909330485')"
				size="mini"
				type="primary"
				@click="dialogCheckType.visible = true"
			>
				身份校验信息
			</el-button>
			<el-button
				v-if="hasPermission('909330487')"
				size="mini"
				type="primary"
				@click="handleEdit($t('member.check_type_title'))"
			>
				安全校验配置
			</el-button>
		</div>
		<el-dialog
			:title="dialogTitle"
			:width="bmhDialog ? '60%' : '35%'"
			:append-to-body="true"
			:destroy-on-close="true"
			:visible.sync="editVisible"
			:close-on-click-modal="false"
			:before-close="closeFormDialog"
			@close="closeFormDialog"
		>
			<div
				v-loading="editLoading"
				element-loading-spinner="el-icon-loading"
			>
				<el-form
					ref="editForm"
					:rules="rules"
					:model="editData"
					label-width="150px"
				>

					<!-- 安全校验 -->
					<div v-if="dialogTitle === $t('member.check_type_title') ">
						<MemberCheckTypeSelect v-model="editData.checkType" :showCheck="(val) => memberCheckTypeShow(val)"  width="150px" label="默认安全校验方式:" />
					</div>


					<!-- 解绑操作 -->
					<div v-if="dialogTitle === $t('member.check_type_unbundle') ">
						<div v-if="dialogCheckType.unbindType === userInfo.checkType">
							<p style="margin-bottom: 15px;">当前重置的{{memberCheckTypeSelectOpts[dialogCheckType.unbindType]}}是安全校验的默认启用项，解绑操作将修改默认安全校验项。</p>
							<MemberCheckTypeSelect v-model="editData.checkType"   width="150px" label="修改安全校验项为:" :showCheck="(val) => Number(val) !== dialogCheckType.unbindType && memberCheckTypeShow(val)" />
						</div>
						<div v-else>
							<p style="margin-bottom: 15px;">当前解绑的{{memberCheckTypeSelectOpts[dialogCheckType.unbindType]}}不是安全校验的默认启用项，解绑操作不会修改默认的安全校验项。</p>
						</div>
					</div>
					<el-form-item
						v-if="dialogTitle === $t('common.account_status')"
						:label="`${$t('common.account_status')}:`"
					>
						<el-checkbox-group v-model="editData.accountStatus">
							<el-checkbox label="1">
								{{ $t('common.login_lock_status') }}
							</el-checkbox>
							<el-checkbox
								:disabled="
									userInfo.liquidationStatus === 1 ||
										userInfo.liquidationStatus === 2
								"
								label="2"
							>
								{{ $t('common.game_lock_status') }}
							</el-checkbox>
							<el-checkbox
								:disabled="
									userInfo.liquidationStatus === 1 ||
										userInfo.liquidationStatus === 2
								"
								label="3"
							>
								{{ $t('common.account_lock_status') }}
							</el-checkbox>
						</el-checkbox-group>
					</el-form-item>
					<el-form-item
						v-if="dialogTitle === $t('common.risk_control_level')"
						:label="`${$t('common.risk_control_level')}:`"
					>
						<el-select
							v-model="editData.windControlId"
							:placeholder="$t('common.please_choose')"
						>
							<el-option
								v-for="item in riskLevelList"
								:key="item.id"
								:label="item.windControlLevelName"
								:value="item.id"
							></el-option>
						</el-select>
					</el-form-item>
					<el-form-item
						v-if="dialogTitle === $t('member.label_name')"
						:label="`${$t('member.label_name')}:`"
					>
						<el-select
							v-model="editData.labelId"
							:placeholder="$t('common.please_choose')"
						>
							<el-option
								v-for="item in memberLabelList"
								:key="item.id"
								:label="item.labelName"
								:value="item.id"
							></el-option>
						</el-select>
					</el-form-item>
					<el-form-item
						v-if="dialogTitle === $t('member.phone_number')"
						:label="`${$t('member.phone_number')}:`"
						required
					>
						<el-col :span="6">
							<el-form-item prop="areaCode">
								<el-select
									v-model="editData.areaCode"
									:placeholder="$t('common.please_choose')"
									@change="handelAreaCode"
								>
									<el-option
										v-for="(item, k) in zonecodeList"
										:key="k"
										:label="item.code"
										:value="item.code"
									></el-option>
								</el-select>
							</el-form-item>
						</el-col>
						<el-col :span="18">
							<el-form-item prop="mobile">
								<el-input
									key="mobile"
									v-model.trim="editData.mobile"
									v-symbols
									clearable
									:maxlength="
										selectedZonecode.len[
											selectedZonecode.len.length - 1
										]
									"
									:placeholder="
										$t(
											'member.please_enter_your_mobile_number'
										)
									"
									:disabled="loading"
									@input="onMobileNumberInput"
								></el-input>
							</el-form-item>
						</el-col>
					</el-form-item>
					<el-form-item
						v-if="dialogTitle === $t('member.date_of_birth')"
						:label="`${$t('member.date_of_birth')}:`"
					>
						<el-date-picker
							v-model="editData.birthday"
							type="date"
							:placeholder="$t('member.select_date')"
							value-format="yyyy-MM-dd"
							:picker-options="timeControl"
						></el-date-picker>
					</el-form-item>

					<el-form-item
						v-if="dialogTitle === $t('member.nickname')"
						:label="`${$t('member.nickname')}:`"
					>
						<el-form-item prop="nickName">
							<el-input
								key="nickName"
								v-model="editData.nickName"
								v-input="{ name: 'noEmpty' }"
								clearable
								type="text"
								size="medium"
								maxlength="12"
								:placeholder="$t('member.nickname_check')"
								@input="handleNickNameInput"
							></el-input>
						</el-form-item>
					</el-form-item>
					<el-form-item
						v-if="dialogTitle === $t('common.name')"
						:label="`${$t('common.name')}:`"
						required
					>
						<el-form-item prop="realName">
							<el-input
								key="realName"
								v-model="editData.realName"
								v-symbols
								clearable
								type="text"
								size="medium"
								maxlength="15"
								:placeholder="
									$t('member.Please_enter_your_name')
								"
								:disabled="loading"
							></el-input>
						</el-form-item>
					</el-form-item>
					<el-form-item
						v-if="dialogTitle === $t('member.gender')"
						:label="`${$t('member.gender')}:`"
					>
						<el-select
							v-model="editData.gender"
							:placeholder="$t('common.please_choose')"
						>
							<el-option
								v-for="item in genderType"
								:key="item.description"
								:label="item.description"
								:value="item.code * 1"
							></el-option>
						</el-select>
					</el-form-item>
					<el-form-item
						v-if="dialogTitle === $t('member.mailbox')"
						:label="`${$t('member.mailbox')}:`"
					>
						<el-input
							key="email"
							v-model.trim="editData.email"
							clearable
							type="email"
							size="medium"
							:maxlength="32"
							:placeholder="
								$t('member.please_enter_your_email_address')
							"
							:disabled="loading"
						></el-input>
					</el-form-item>
					<el-form-item
						v-if="dialogTitle === $t('member.credit_rating')"
						:label="`${$t('member.credit_rating')}:`"
						required
					>
						<el-select
							v-model="editData.creditLevel"
							:placeholder="$t('common.please_choose')"
						>
							<el-option
								v-for="item in creditLevelList"
								:key="item"
								:label="item"
								:value="item"
							></el-option>
						</el-select>
					</el-form-item>
					<el-form-item
						v-if="dialogTitle === $t('member.login_password_reset')"
						label=""
					>
						<div style="line-height:20px">
							{{ $t('member.reset_succeeded_password') }}
							<span style="color:#1990ff">
								{{ resetPassword }}
							</span>
							<i
								class="el-icon-document-copy"
								@click="copy(resetPassword)"
							/>
							<br />
							{{ $t('member.reset_succeeded_password_tip') }}
						</div>
					</el-form-item>
					<el-form-item
						v-if="
							dialogTitle ===
								$t('member.withdrawals_password_reset')
						"
						:label="`${$t('member.pay_password_set')}:`"
					>
						<el-input
							v-model="editData.resetPayPassword"
							clearable
							type="text"
							size="medium"
							disabled
						></el-input>
					</el-form-item>
					<el-form-item
						v-if="dialogTitle === $t('member.rebate_status')"
						:label="`${$t('member.rebate_status')}:`"
					>
						<el-radio-group v-model="editData.rebateFreezeStatus">
							<el-radio :label="0">
								{{ $t('common.account_status_normal') }}
							</el-radio>
							<el-radio :label="1">
								{{ $t('common.account_status_suspend') }}
							</el-radio>
						</el-radio-group>
					</el-form-item>
					<el-form-item
						v-if="dialogTitle === $t('member.bmh_account_unbind')"
					>
						<p>{{ $t('member.bmh_text_1') }}</p>
						<p>{{ $t('member.bmh_text_2') }}</p>
					</el-form-item>
					<el-form-item
						v-if="dialogTitle === $t('member.yh_account_unbind')"
					>
						<p>{{ $t('member.yh_text_1') }}</p>
						<p>{{ $t('member.yh_text_2') }}</p>
					</el-form-item>

					<el-form-item :label="remarkTitle" prop="remark">
						<el-input
							v-model.trim="editData.remark"
							maxlength="500"
							type="textarea"
							show-word-limit
							clearable
							:placeholder="$t('common.please_enter')"
						></el-input>
					</el-form-item>
				</el-form>
				<div slot="footer" class="dialog-footer">
					<el-button @click="closeFormDialog">
						{{ $t('common.cancel') }}
					</el-button>
					<el-button
						type="primary"
						:disabled="editLoading"
						:loading="editLoading"
						@click="submitEdit"
					>
						{{ $t('common.sure') }}
					</el-button>
					<p
						v-if="dialogTitle === $t('common.name')"
						style="color:#ff4404;margin:15px 0px;"
					>
						【{{ $t('member.be_careful') }}】
					</p>
				</div>
			</div>
		</el-dialog>

		<el-dialog 
			title="身份校验信息"
			:visible.sync="dialogCheckType.visible"
			width="550px"
			:append-to-body="true"
			:destroy-on-close="true"
		>
			<div  slot="footer"></div>
			<el-form label-width="100px">
				<el-form-item label="身份验证器:">
					<span class="unbundle-span">
						{{  userInfo.googleSecretBindStatus === 1 ? '已启用' : '未启用'  }}  
					</span>
					<el-button
						type="primary"
						size="mini"
						:disabled=" userInfo.googleSecretBindStatus  === 0"
						@click="handleEdit($t('member.check_type_unbundle'), 1)"
					>
						解绑
					</el-button>
				</el-form-item>
				<el-form-item label="邮箱:">
					<span class="unbundle-span">
						{{  userInfo.email || '-'  }}
					</span>
						<!-- :disabled="!userInfo.email" -->
					<el-button
						type="primary"
						size="mini"
						:disabled="!userInfo.email"
						@click="handleEdit($t('member.check_type_unbundle'), 2)"
					>
						解绑
					</el-button>
				</el-form-item>
				<el-form-item label="手机号:">
					<span class="unbundle-span">	{{ userInfo.mobile || '-' }}</span>
					<el-button
						type="primary"
						size="mini"
						:disabled="!userInfo.mobile"
						@click="handleEdit($t('member.check_type_unbundle'), 3)"
					>
						解绑
					</el-button>
				</el-form-item>
			</el-form>


		</el-dialog>

		<GoogleKeyInput
			:isShowdialog="isShowGoogleKeyInput"
			@getGoogleKey="handleGoogleKeyInput"
			@backPrevStep="backPrevStep()"
			:submitLoading="googleKeyLoading"
		></GoogleKeyInput>
		<!-- <el-dialog
			:title="dialogTitle"
			:append-to-body="true"
			:destroy-on-close="true"
			:close-on-click-modal="false"
			:visible.sync="activityVisible"
			:before-close="closeFormDialog"
			width="50%"
		>
			<el-table
				v-loading="loading"
				border
				size="mini"
				class="small-size-table"
				:data="activityFlowList"
				:header-row-style="{ height: '24px', lineHeight: '24px' }"
				style="margin-top: 10px; z-index: 0"
				:header-cell-style="getRowClass"
				highlight-current-row
			>
				<el-table-column
					align="center"
					prop="gameCode"
					:label="`${$t('member.venue_wallet')}`"
				>
					<template slot-scope="scope">
						<span v-if="scope.row.gameCode === 'center'">
							{{ $t('member.center_wallet') }}
						</span>
						<span v-else>
							{{ filterName(scope.row.gameCode) }}
						</span>
					</template>
				</el-table-column>
				<el-table-column
					prop="taskType"
					width="165px"
					align="center"
					:label="`${$t('member.task_type')}`"
				>
					<template slot-scope="scope">
						{{ typeFilter(scope.row.taskType, 'taskType') }}
					</template>
				</el-table-column>
				<el-table-column
					prop="approveTime"
					align="center"
					:label="`${$t('member.approve_time')}`"
				></el-table-column>
				<el-table-column
					prop="difBillAmount"
					align="center"
					:label="`${$t('member.dif_bill_amount')}`"
				>
					<template slot-scope="scope">
						{{ handleCurrency(parentData.currency) }}
						{{
							handleNumber(
								parentData.currency,
								scope.row.difBillAmount
							)
						}}
					</template>
				</el-table-column>
				<el-table-column
					prop="balance"
					align="center"
					:label="`${$t('member.balance_of_venue_wallet')}`"
				>
					<template slot-scope="scope">
						{{ handleCurrency(parentData.currency) }}
						{{
							handleNumber(parentData.currency, scope.row.balance)
						}}
					</template>
				</el-table-column>
				<el-table-column
					prop="userId"
					align="center"
					:label="`${$t('common.actions')}`"
				>
					<template slot-scope="scope">
						<el-button
							type="primary"
							@click="relieveLimit(scope.row)"
						>
							{{ $t('member.remove_flow_restriction') }}
						</el-button>
					</template>
				</el-table-column>
			</el-table>
			<div slot="footer" class="dialog-footer">
				<el-button @click="closeFormDialog">
					{{ $t('member.close') }}
				</el-button>
			</div>
		</el-dialog> -->
	</div>
</template>
<script>
import list from '@/mixins/list'
// import { getVenueList } from '@/api/game'
import { rules } from './rules'
import { NO_SPECIAL_CHAR } from '@/utils/pattern'
import { getNewSubStrAndLen } from '@/utils/validate'
export default {
	mixins: [list],
	components: {
		MemberCheckTypeSelect:  () => import('@/components/MemberCheckTypeSelect'),
		GoogleKeyInput: () => import('@/components/GoogleKeyInput')
	},
	props: {
		parentData: { type: Object, default: () => ({}) },
		parentRefresh: { type: Function, default: () => null },
		userInfo: { type: Object, default: {} },
		btnPower: { type: Array, default: [] }
	},
	data() {
		return {
			memberCheckTypeSelectOpts: {
				0: '无校验',
				1: '身份验证器',
				2: '邮箱校验',
				3: '手机校验'
			},
			isShowGoogleKeyInput: false,
			googleKeyLoading: false,
			dialogCheckType: {
				visible: false,
				// 1 authenticatorsAfter
				// 2 emailAfter
				// 3 mobileAfter
				unbindType: undefined
			},
			dialogTitle: '',
			bmhDialog: false,
			editData: {
				accountStatus: [],
				windControlId: '',
				labelId: '',
				birthday: '',
				nickName: '',
				realName: '',
				areaCode: '',
				mobile: '',
				gender: '',
				email: '',
				resetPayPassword: '',
				remark: '',
				creditLevel: '',
				bmhUserId: '',
				yihuanUserId: '',
				rebateFreezeStatus: '',
				checkType: undefined
			},
			// infoObj: {},
			riskLevelList: [],
			memberLabelList: [],
			creditLevelList: [],
			zonecodeList: [],
			editVisible: false,
			editLoading: false,
			timeControl: {
				disabledDate: (time) => {
					return time.getTime() > Date.now()
				}
			},
			remarkTitle: this.$t('member.submit_comments'),
			selectedZonecode: {
				len: []
			},
			// activityVisible: false,
			// activityFlowList: [],
			// btnPower: [],
			// gameVenueList: [],
			preMemberRebateState: 0,
			refreshLoading: false
		}
	},
	computed: {
		rules,
		genderType() {
			return this.globalDics.genderType || []
		}
	},
	watch: {
		'editData.windControlId': {
			handler(newVal) {
				for (let i = 0; i < this.riskLevelList.length; i++) {
					const ele = this.riskLevelList[i]
					if (newVal === ele.id) {
						this.editData.windControlName = ele.windControlLevelName
					}
				}
			},
			deep: true
		},
		'editData.labelId': {
			handler(newVal) {
				for (let i = 0; i < this.memberLabelList.length; i++) {
					const ele = this.memberLabelList[i]
					if (newVal === ele.id) {
						this.editData.labelName = ele.labelName
					}
				}
			},
			deep: true
		}
	},
	created() {
		this.refreshLoading = true
		Promise.all([
			this.getWindControllerLevelDict(),
			this.getMemberLabelDict(),
			this.getCreditLevelList(),
			this.getZonecode()
			// this.getUserInfo()
			// this.getVenueList()
		]).finally(() => {
			this.refreshLoading = false
		})
	},
	methods: {
		backPrevStep() {
			this.isShowGoogleKeyInput = false
		},
		memberCheckTypeShow(val) {
			if (Number(val) === 0) return true
			if (Number(val) === 1) return  this.userInfo.googleSecretBindStatus  === 1
			if (Number(val) === 2) return  this.userInfo.email
			if (Number(val) === 3) return  this.userInfo.mobile
		},
		async handleGoogleKeyInput(googleAuthCode) {
			try {
				this.googleKeyLoading = true
				await this.$api.checkInformation({
					googleAuthCode
				})
				const data = {}
				const params = this.editData
				data.userName = this.parentData.userName
				data.merchantId = this.parentData.merchantId
				data.userId = this.parentData.userId
				data.checkType = this.userInfo.checkType
				// 解绑
				if (this.dialogTitle === this.$t('member.check_type_unbundle')){
					const afterKeys = {
						1: 'authenticatorsAfter',
						2: 'emailAfter',
						3: 'mobileAfter'
					}
					const itemObj = {
						1: {
							authenticators: this.userInfo.googleSecretBindStatus
						},
						2: {
							email: this.userInfo.email
						},
						3: {
							mobile: this.userInfo.mobile
						}
					}
					const key = afterKeys[this.dialogCheckType.unbindType]
					const obj = {
						remark: params.remark,
						...itemObj[this.dialogCheckType.unbindType] || {}
					}
					
					if (this.editData.checkType !== undefined) {
						obj['checkType'] =  this.editData.checkType
					}
					

					// if (this.dialogCheckType.unbindType !== this.userInfo.checkType) {
					// 	obj.checkType = -1
					// }

					data[key] = obj
				}
				if (this.dialogTitle === this.$t('member.check_type_title')){
					data.securityAfter = {
						checkType: params.checkType,
						remark: params.remark,
					}
				}

				this.setMemberInfoEdit(data)
				
			} catch (error) {
				console.log(error)
				this.googleKeyLoading = false
			}
		},
		handleInput(val) {
			this.editData.remark = val.replace(NO_SPECIAL_CHAR, '')
		},
		// 字母数字长度为1，汉字长度为2,总计不超过12个
		handleNickNameInput(val) {
			const { newStr } = getNewSubStrAndLen(val)
			this.editData.nickName = newStr
		},
		// async getVenueList() {
		// 	const res = await getVenueList({
		// 		pageNum: 1,
		// 		pageSize: 9999
		// 	})
		// 	if (res) {
		// 		this.gameVenueList = res?.data?.record
		// 	}
		// },
		// filterName(gameCode) {
		// 	return this.gameVenueList.find(
		// 		(item) => item.venueCode === gameCode
		// 	)?.walletNamesJson?.[this.getKey('name', { index: 0, zh: true })]
		// },
		// getUserInfo() {
		// 	return this.$api
		// 		.getOutlineInfo({ ...this.parentData })
		// 		.then((res) => {
		// 			this.btnPower = []
		// 			this.infoObj = res?.data || {}
		// 			const { auditList } = res?.data
		// 			auditList.forEach((ele) => {
		// 				this.btnPower.push(ele.applyType)
		// 			})
		// 		})
		// 		.catch(() => {})
		// },
		handleEdit(val, params) {
			const {
				loginLockStatus,
				gameLockStatus,
				paymentLockStatus,
				windControlId,
				labelId,
				gender,
				creditLevel,
				yihuanUserId,
				rebateFreezeStatus,
				bmhUserId
			} = this.userInfo
			// this.infoObj
			this.remarkTitle = this.$t('member.submit_comments')
			this.editData.remark = ''
			this.dialogTitle = val
			this.editVisible = true
		
			switch (val) {
				case this.$t('common.account_status'):
					this.editData.accountStatus = []
					if (loginLockStatus === 1) {
						this.editData.accountStatus.push('1')
					}
					if (gameLockStatus === 1) {
						this.editData.accountStatus.push('2')
					}
					if (paymentLockStatus === 1) {
						this.editData.accountStatus.push('3')
					}
					break
				case this.$t('common.risk_control_level'):
					// this.editData.windControlId =
					// 	windControlId + '' === '0' ? '' : windControlId
					this.editData.windControlId = undefined
					for (const item of this.riskLevelList) {
						if (windControlId === item.id) {
							this.editData.windControlId = windControlId
							break
						}
					}
					break
				case this.$t('member.label_name'):
					this.editData.labelId = labelId + '' === '0' ? '' : labelId
					this.remarkTitle = this.$t('member.submit_review_comments')
					break
				case this.$t('member.date_of_birth'):
					this.editData.birthday = ''
					this.remarkTitle = this.$t('member.submit_review_comments')
					break
				case this.$t('member.phone_number'):
					this.editData.areaCode = ''
					this.editData.mobile = ''
					this.remarkTitle = this.$t('member.submit_review_comments')
					break
				case this.$t('common.name'):
					this.editData.realName = ''
					this.remarkTitle = this.$t('member.submit_review_comments')
					break
				case this.$t('member.nickname'):
					this.editData.nickName = ''
					this.remarkTitle = this.$t('member.submit_review_comments')
					break
				case this.$t('member.gender'):
					this.remarkTitle = this.$t('member.submit_review_comments')
					this.editData.gender = gender === -1 ? '' : gender
					break
				case this.$t('member.mailbox'):
					this.editData.email = ''
					this.remarkTitle = this.$t('member.submit_review_comments')
					break
				case this.$t('member.credit_rating'):
					this.editData.creditLevel = creditLevel
					break
				// case this.$t('member.activity_flow_limit'):
				// 	this.getActivityFlow()
				// 	break
				case this.$t('member.login_password_reset'):
					this.resetPassword = ''
					this.setRandomPassword(8)
					break
				case this.$t('member.withdrawals_password_reset'):
					this.editData.resetPayPassword = this.btnPower.includes(10)
						? '审核中'
						: '密码重置'
					this.remarkTitle = this.$t('member.review_remarks')
					break

				case this.$t('member.rebate_status'):
					this.preMemberRebateState = rebateFreezeStatus
					this.editData.rebateFreezeStatus = rebateFreezeStatus
					this.remarkTitle = this.$t('member.submit_comments')
					break

				case this.$t('member.bmh_account_unbind'):
					this.bmhDialog = true
					this.editData.bmhUserId = bmhUserId
					this.remarkTitle = this.$t('member.submit_review_comments')
					break
				case this.$t('member.yh_account_unbind'):
					this.bmhDialog = true
					this.editData.yihuanUserId = yihuanUserId
					this.remarkTitle = this.$t('member.submit_review_comments')
				case this.$t('member.check_type_unbundle'):
					this.editData.checkType = undefined
					this.editData.remark = ''
					this.dialogCheckType.unbindType = params
					this.dialogCheckType.visible = false
					break
				case this.$t('member.check_type_title'): 
					this.editData.checkType = this.userInfo.checkType
					this.editData.remark = ''
					break
				default:
					this.remarkTitle = this.$t('member.submit_comments')
					break
			}
		
			// this.editVisible = val !== this.$t('member.activity_flow_limit')
			// this.activityVisible = val === this.$t('member.activity_flow_limit')
		},
		submitEdit() {
			const data = {}
			const params = this.editData
			data.userName = this.parentData.userName
			data.merchantId = this.parentData.merchantId
			data.userId = this.parentData.userId
			this.$refs.editForm.validate((valid) => {
				if (valid) {
					switch (this.dialogTitle) {
						case this.$t('member.check_type_unbundle'):
							this.isShowGoogleKeyInput = true
							this.editVisible = false
							break
						case this.$t('member.check_type_title'): 
							this.isShowGoogleKeyInput = true
							this.editVisible = false
							break
						case this.$t('common.account_status'):
							data.accountStatusAfter = {
								loginLockStatus: params.accountStatus.includes(
									'1'
								)
									? 1
									: 0,
								gameLockStatus: params.accountStatus.includes(
									'2'
								)
									? 1
									: 0,
								paymentLockStatus: params.accountStatus.includes(
									'3'
								)
									? 1
									: 0,
								remark: params.remark
							}
							this.setMemberInfoEdit(data)
							break
						case this.$t('common.risk_control_level'):
							data.windControlAfter = {
								windControlId: params.windControlId,
								windControlName: this.editData.windControlName,
								remark: params.remark
							}
							this.setMemberInfoEdit(data)
							break
						case this.$t('member.label_name'):
							data.labelAfter = {
								labelId: params.labelId,
								labelName: params.labelName,
								remark: params.remark
							}
							this.setMemberInfoEdit(data)
							break
						case this.$t('member.date_of_birth'):
							data.birthAfter = {
								birth: params.birthday,
								remark: params.remark
							}
							this.setMemberInfoEdit(data)
							break
						case this.$t('member.phone_number'):
							data.mobileAfter = {
								areaCode: params.areaCode,
								mobile: params.mobile,
								remark: params.remark
							}
							this.setMemberInfoEdit(data)
							break
						case this.$t('common.name'):
							data.realNameAfter = {
								realName: params.realName,
								remark: params.remark
							}
							this.setMemberInfoEdit(data)
							break
						case this.$t('member.nickname'):
							data.nickNameAfter = {
								nickName: params.nickName,
								remark: params.remark
							}
							this.setMemberInfoEdit(data)
							break
						case this.$t('member.gender'):
							data.genderAfter = {
								gender: params.gender,
								remark: params.remark
							}
							this.setMemberInfoEdit(data)
							break
						case this.$t('member.mailbox'):
							data.emailAfter = {
								email: params.email,
								remark: params.remark
							}
							this.setMemberInfoEdit(data)
							break
						case this.$t('member.login_password_reset'):
							data.resetPwdAfter = {
								newPassword: this.resetPassword,
								resetPwdRemark: params.remark
							}
							this.setMemberInfoEdit(data)
							break
						case this.$t('member.withdrawals_password_reset'):
							data.resetPayPasswordAfter = {
								resetPwdRemark: params.remark
							}
							this.setMemberInfoEdit(data)
							break
						case this.$t('member.bmh_account_unbind'):
							data.remark = params?.remark
							data.bmhUserId = params.bmhUserId
							this.setBmhMemberInfoEdit(data)
							break
						case this.$t('member.yh_account_unbind'):
							;(data.remark = params.remark),
								(data.yihuanUserId = params.yihuanUserId)
							this.setYhMemberInfoEdit(data)
							break
						case this.$t('member.account_remarks'):
							data.userId = this.parentData.userId
							data.remark = params.remark
							this.getMemberRemarkAdd(data)
							break
						case this.$t('member.credit_rating'):
							data.creditLevelAfter = {
								creditLevel: params.creditLevel,
								remark: params.remark
							}
							this.setMemberInfoEdit(data)
							break
						case this.$t('member.rebate_status'):
							if (
								params.rebateFreezeStatus === 0 &&
								this.preMemberRebateState === 1
							) {
								// 会员返水状态由冻结变成正常
								// data.unfreezeAt = dayjs().format('YYYY-MM-DD')
								// data.unfreezeBy = ""
								data.freezeStatus = params.rebateFreezeStatus
								data.unfreezeRemark = params.remark
								this.setMemberRebateStatusEdit(data)
							}
							if (
								params.rebateFreezeStatus === 1 &&
								this.preMemberRebateState === 0
							) {
								// 会员返水状态由冻结变成正常
								// data.freezeAt = dayjs().format('YYYY-MM-DD')
								// data.freezeBy = ""
								data.freezeRemark = params.remark
								data.freezeStatus = params.rebateFreezeStatus
								this.setMemberRebateStatusEdit(data)
							}
							break
					}
				} else {
					return false
				}
			})
		},
		// 编辑信息
		setMemberInfoEdit(val, callback) {
			this.editLoading = true
			this.$api
				.setMemberInfoEdit(val)
				.then((res) => {
					// 去掉活动流水限制
					// if (
					// 	this.dialogTitle !== this.$t('member.activity_flow_limit')
					// ) {
					// 	this.$refs.editForm.clearValidate()
					// 	this.$message.success(this.$t('common.action_success'))
					// 	this.editVisible = false
					// } else {
					// 	this.activityVisible = false
					// 	this.$message.success(
					// 		this.$t('member.cancellation_succeeded')
					// 	)
					// }
					
					if (res.code === 200) {
						this.$refs.editForm.resetFields()
						this.$message.success(this.$t('common.action_success'))
						this.editVisible = false
						this.editLoading = false
						this.isShowGoogleKeyInput = false
						this.googleKeyLoading = false
						// this.getUserInfo()
						this.$emit('parentRefresh')
					}
				})
				.catch(() => {
					this.editLoading = false
					this.isShowGoogleKeyInput = false
				})
		},
		// 编辑会员返水状态
		setMemberRebateStatusEdit(val) {
			this.editLoading = true
			this.$api
				.rebateStatusFreezeRecordSaveOrUpdate(val)
				.then((res) => {
					if (res.code === 200) {
						this.$refs.editForm.resetFields()
						this.$message.success(this.$t('common.action_success'))
						this.editVisible = false
						this.$emit('parentRefresh')
					}
				})
				.catch(() => {
					this.editLoading = false
				})
		},
		// 白马会解绑提交
		setBmhMemberInfoEdit(val) {
			this.editLoading = true
			this.$api
				.setBmhMemberInfoEdit(val)
				.then((res) => {
					if (res.code === 200) {
						this.$refs.editForm.resetFields()
						this.$message.success(this.$t('common.modify_success'))
						this.editVisible = false
						this.editLoading = false
						this.bmhDialog = false
						// this.getUserInfo()
						this.$emit('parentRefresh')
					}
				})
				.catch(() => {
					this.editLoading = false
				})
		},
		// 易换账号解绑提交
		setYhMemberInfoEdit(val) {
			this.editLoading = true
			this.$api
				.setYhMemberInfoEdit(val)
				.then((res) => {
					if (res.code === 200) {
						this.$refs.editForm.resetFields()
						this.$message.success(this.$t('common.modify_success'))
						this.editVisible = false
						this.editLoading = false
						this.bmhDialog = false
						// this.getUserInfo()
						this.$emit('parentRefresh')
					}
				})
				.catch(() => {
					this.editLoading = false
				})
		},
		// 编辑备注
		getMemberRemarkAdd(val) {
			this.editLoading = true
			this.$api
				.getMemberRemarkAdd(val)
				.then((res) => {
					this.$message.success(this.$t('common.modify_success'))
					this.$refs.editForm.resetFields()
					this.editVisible = false
					this.editLoading = false
					// this.getUserInfo()
					this.$emit('parentRefresh')
				})
				.catch(() => {
					this.editLoading = false
				})
		},
		refresh() {
			// this.getUserInfo()
			this.refreshLoading = true
			Promise.all([
				this.getWindControllerLevelDict(),
				this.getMemberLabelDict(),
				this.getCreditLevelList(),
				this.getZonecode()
			]).finally(() => {
				this.$emit('parentRefresh')
				this.refreshLoading = false
			})
		},
		closeFormDialog() {
			// if (this.dialogTitle !== this.$t('member.activity_flow_limit')) {
			// 	this.$refs.editForm.resetFields()
			// 	this.$refs.editForm.clearValidate()
			// 	this.editVisible = false
			// } else {
			// 	this.activityVisible = false
			// }
			if (this.dialogTitle !== this.$t('member.check_type_unbundle') && this.dialogTitle !== this.$t('member.check_type_title')) {
				this.$refs.editForm.resetFields()
			}
			this.editVisible = false
			this.bmhDialog = false
		},
		// 解除流水限制
		// relieveLimit(val) {
		// 	this.$confirm(`${this.$t('member.flow_limit_tips')}`, {
		// 		center: true,
		// 		confirmButtonText: this.$t('common.confirm'),
		// 		cancelButtonText: this.$t('common.cancel'),
		// 		customClass: 'memberMsgBox'
		// 	})
		// 		.then(() => {
		// 			const params = {
		// 				activityTaskLimitAfter: {
		// 					gameCode: val.gameCode,
		// 					taskType: val.taskType
		// 				},
		// 				userName: this.parentData.userName,
		// 				merchantId: this.parentData.merchantId
		// 			}
		// 			this.setMemberInfoEdit(params)
		// 		})
		// 		.catch(() => {})
		// },
		// 获取活动流水限制
		// getActivityFlow(val) {
		// 	this.$api
		// 		.getActivityTaskLimitList({
		// 			...this.parentData
		// 		})
		// 		.then((res) => {
		// 			this.activityFlowList = res.data
		// 		})
		// 		.catch(() => {})
		// },
		// 获取风控层级
		getWindControllerLevelDict() {
			return this.$api
				.getSelectWindControlLevel({
					windControlType: 1,
					merchantId: this.parentData.merchantId
				})
				.then((res) => {
					this.riskLevelList = res?.data || []
				})
		},
		// 获取会员标签
		getMemberLabelDict() {
			return this.$api
				.getMemberLabelDict({
					labelType: 0,
					merchantId: this.parentData.merchantId
				})
				.then((res) => {
					this.memberLabelList = res?.data || []
				})
		},
		// 获取信用等级
		getCreditLevelList() {
			return this.$api.getCreditLevelConfcreditList().then((res) => {
				this.creditLevelList = res?.data || []
			})
		},
		// 手机长度校验
		getZonecode() {
			const params = {
				k: 'obbw.zonecode.cellphone.msg',
				pageNum: 1,
				pageSize: 10
			}
			return this.$api.getkvconfigQueryList(params).then((res) => {
				this.zonecodeList = JSON.parse(res.data.records[0].v) || []
				if (this.zonecodeList.length) {
					this.selectedZonecode = this.zonecodeList[0]
					this.editData.areaCode = this.zonecodeList[0].code
				}
			})
		},
		handelAreaCode(val) {
			this.selectedZonecode = this.zonecodeList.find(
				(item) => val === item.code
			)
			this.editData.areaCode = val
			this.editData.mobile = ''
		},
		onMobileNumberInput() {
			this.editData.mobile = this.editData.mobile.replace(/[^\d]+/g, '')
		}
	}
}
</script>
<style lang="scss" scoped>
.btn-list-box {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	.backgroundTitelBox {
		width: 180px;
		height: 40px;
		text-align: center;
		line-height: 40px;
		background: #000;
		color: rgb(255, 255, 255);
		margin: 20px;
		margin-left: 0;
	}
	.editMsg {
		text-align: center;
		line-height: 18px;
		padding: 0 20px;
		margin-left: 20px;
		border-left: 1px solid #ccc;
		i {
			font-size: 18px;
			font-weight: bold;
			margin-bottom: 5px;
		}
	}
}
::v-deep .el-dialog__header {
	color: #909399;
	font-weight: 700;
}
.dialog-footer {
	text-align: center;
}
::v-deep .el-textarea .el-input__count {
	bottom: unset;
}

.unbundle-span{
	display: inline-block;
	width: 170px;
}
</style>
